package com.lb.jwitter.action;


import java.util.List;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; 
import org.springframework.test.context.ContextConfiguration;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.lb.jwitter.service.ConditionReport; 
 import java.util.Map; 
import com.opensymphony.xwork2.ActionContext; 
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQLDTTXAQuiDinhHocPhi;
import com.lb.jwitter.service.TblQLDTTXAQuiDinhHocPhiService;
import com.lb.jwitter.service.TblQuyenChiTietService;import com.lb.jwitter.service.TblTaiKhoan;import com.lb.jwitter.service.TblQLDTTXAHocVienDonXinXetMienGiam;
import com.lb.jwitter.service.TblQLDTTXAHocVienDonXinXetMienGiamService;
import com.lb.jwitter.service.TblQLDTTXAHocVien;
import com.lb.jwitter.service.TblQLDTTXAHocVienService;

import com.lb.jwitter.service.TblQLDTTXAHocVienMienGiam;
import com.lb.jwitter.service.TblQLDTTXAHocVienMienGiamService;

import com.lb.jwitter.service.TblQLDTTXAMonHoc;
import com.lb.jwitter.service.TblQLDTTXAMonHocService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAHocVienDonXinXetMienGiamEditFormAction{
	
	private int id;
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    private int page; 
    public int getPage() { return page; }

    public void setPage(int page) { this.page = page; }

    private int pages; 
    public int getPages() { return pages; }

    public void setPages(int pages) { this.pages = pages; }
    
    private TblQLDTTXAQuiDinhHocPhi tblQLDTTXAQuiDinhHocPhi; 
    public TblQLDTTXAQuiDinhHocPhi getTblQLDTTXAQuiDinhHocPhi() {
        return tblQLDTTXAQuiDinhHocPhi; 
      } 

    private TblQLDTTXAQuiDinhHocPhiService tblQLDTTXAQuiDinhHocPhiService; 
    private TblQLDTTXAHocVienDonXinXetMienGiam tblQLDTTXAHocVienDonXinXetMienGiam; 
    public TblQLDTTXAHocVienDonXinXetMienGiam getTblQLDTTXAHocVienDonXinXetMienGiam() { 
        return tblQLDTTXAHocVienDonXinXetMienGiam; 
    } 
    private List<TblQLDTTXAHocVienDonXinXetMienGiam> tblQLDTTXAHocVienDonXinXetMienGiams; 
    public List<TblQLDTTXAHocVienDonXinXetMienGiam>  getTblQLDTTXAHocVienDonXinXetMienGiams() {
         return tblQLDTTXAHocVienDonXinXetMienGiams; 
      } 

    private TblQLDTTXAHocVienDonXinXetMienGiamService tblQLDTTXAHocVienDonXinXetMienGiamService; 

    private List<TblQLDTTXAHocVien> tblQLDTTXAHocViens; 
    public List<TblQLDTTXAHocVien>  getTblQLDTTXAHocViens(){ 
              return tblQLDTTXAHocViens; 
     } 

    private TblQLDTTXAHocVienService tblQLDTTXAHocVienService; 

    private List<TblQLDTTXAHocVienMienGiam> tblQLDTTXAHocVienMienGiams; 
    public List<TblQLDTTXAHocVienMienGiam>  getTblQLDTTXAHocVienMienGiams(){ 
              return tblQLDTTXAHocVienMienGiams; 
     } 

    private TblQLDTTXAHocVienMienGiamService tblQLDTTXAHocVienMienGiamService; 

    private List<TblQLDTTXAMonHoc> tblQLDTTXAMonHocs; 
    public List<TblQLDTTXAMonHoc>  getTblQLDTTXAMonHocs(){ 
              return tblQLDTTXAMonHocs; 
     } 

    private TblQLDTTXAMonHocService tblQLDTTXAMonHocService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
 public String execute() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_HocVien_DonXinXetMienGiam", "sua")){ 
        return "noprivilege"; 
    }        tblQLDTTXAHocVienDonXinXetMienGiamService = (TblQLDTTXAHocVienDonXinXetMienGiamService) context.getBean("tbl_QLDTTXA_HocVien_DonXinXetMienGiamClient"); 
        tblQLDTTXAHocVienService = (TblQLDTTXAHocVienService) context.getBean("tbl_QLDTTXA_HocVienClient"); 

        tblQLDTTXAHocVienMienGiamService = (TblQLDTTXAHocVienMienGiamService) context.getBean("tbl_QLDTTXA_HocVien_MienGiamClient"); 

        tblQLDTTXAMonHocService = (TblQLDTTXAMonHocService) context.getBean("tbl_QLDTTXA_MonHocClient"); 
        tblQLDTTXAQuiDinhHocPhiService = (TblQLDTTXAQuiDinhHocPhiService) context.getBean("tbl_QLDTTXA_QuiDinhHocPhiClient"); 

        tblQLDTTXAHocVienDonXinXetMienGiam = tblQLDTTXAHocVienDonXinXetMienGiamService.gettblQLDTTXAHocVienDonXinXetMienGiam(new Long(id)); 
        tblQLDTTXAHocViens = tblQLDTTXAHocVienService.findAlltblQLDTTXAHocVien(0, 0);
        List<TblQLDTTXAQuiDinhHocPhi> tblQLDTTXAQuiDinhHocPhis = tblQLDTTXAQuiDinhHocPhiService.findAlltblQLDTTXAQuiDinhHocPhi(20, 1);
        if (!tblQLDTTXAQuiDinhHocPhis.isEmpty()){
      	  tblQLDTTXAQuiDinhHocPhi = tblQLDTTXAQuiDinhHocPhis.get(0);
        }
   List<ConditionReport> cons = new ArrayList<ConditionReport>(); 
   if (id != 0) 
   { 
       ConditionReport con = new ConditionReport(); 
       con.setCol("donMGId.id"); 
       con.setValue1(new Long(id)); 
       con.setOperator("eq"); 
       cons.add(con); 
   } 
   tblQLDTTXAHocVienMienGiams = tblQLDTTXAHocVienMienGiamService.findtblQLDTTXAHocVienMienGiamByCondition(cons, pageSize, page); 
      tblQLDTTXAMonHocs =       tblQLDTTXAMonHocService.findAlltblQLDTTXAMonHoc(0, 0); 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_QLDTTXA_HocVien_DonXinXetMienGiam Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 }

public int getId() {
	return id;
}

public void setId(int id) {
	this.id = id;
} 
 } 
 
